<template>
	<view class="content">
		<view class="form-area">
			<u--form labelPosition="left" :model="form" ref="uForm">
				<u-form-item label="名称" prop="name" borderBottom required>
					<u--input v-model="form.name" border="none" placeholder="请输入名称"></u--input>
				</u-form-item>
				<u-form-item label="备注" prop="remarks">
					<u--input v-model="form.remarks" border="none" placeholder="请输入备注"></u--input>
				</u-form-item>
			</u--form>
		</view>
		<view class="" style="margin-top: 60rpx;padding: 0 24rpx;">
			<u-button text="保存" @click="submit" type="success"></u-button>
		</view>
		
	</view>
</template>

<script>
	import {
		addSzledger
	} from '@/api/ledger.js'
	export default {
		data() {
			return {
				form: {
					name: '',
					remarks: '',
					pid: ''
				},
			}
		},
		onLoad(query) {
			console.log('路径参数：', query)
		},
		onShow() {

		},
		methods: {
			submit() {
				if (!this.form.name) {
					uni.showToast({
						title: '请输入名称',
						icon: 'none'
					})
					return;
				}
				addSzledger(this.form).then(res => {
					uni.showToast({
						title: '保存成功',
						icon: 'success',
						complete() {
							uni.navigateBack()
						}
					})
				})
			}
		}
	}
</script>

<style scoped lang="scss">
	.content {
		
	}
	.form-area {
		background-color: #fff;
		padding: 0 24rpx;
	}
</style>